/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.five9.util;

import java.util.logging.ErrorManager;
import java.util.logging.Handler;
import java.util.logging.LogRecord;

/**
 *
 * @author nromero
 */
public class ConsoleLogger extends Handler {

    @Override
    public void publish(LogRecord record) {
        String message = null;
        //check if the record is loggable
        if (!isLoggable(record)) {
            return;
        }
        try {
            message = getFormatter().format(record);
        } catch (Exception e) {
            reportError(null, e, ErrorManager.FORMAT_FAILURE);
        }

        try {
            System.out.print(message + System.getProperty("line.separator"));
        } catch (Exception ex) {
            reportError(null, ex, ErrorManager.WRITE_FAILURE);
        }
        System.out.println(record);
    }

    @Override
    public void flush() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void close() throws SecurityException {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}
